package com.pzl.simple.wvlib;

import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.webkit.JavascriptInterface;

/**
 * 处于webview进程里
 */
public class JsInterfaceTool {

    private Context context;
    private Handler handler;

    public JsInterfaceTool(Context context, Handler handler) {
        this.context = context;
        this.handler = handler;
    }

    @JavascriptInterface
    public void handleJsCall(final String cmd, final String param) {
        Log.i("jinx", "JsInterfaceTool.handleJsCall\n进程 = " + Utils.getCurProcessName(context) + "\n"
                + "线程 = " + Thread.currentThread().getName());

        Message msg = Message.obtain();
        msg.what = 1001;
        Bundle bundle = new Bundle();
        bundle.putString("cmd", cmd);
        bundle.putString("param", param);
        msg.setData(bundle);
        handler.sendMessage(msg);

    }


}
